home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxmclip.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.8 KB  |  106 lines

  1. /* Copyright (C) 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxmclip.h,v 1.2 2000/09/19 19:00:39 lpd Exp $ */
  20. /* Mask clipping device and interface */
  21. /* Requires gxdevice.h, gxdevmem.h */
  22.  
  23. #ifndef gxmclip_INCLUDED
  24. #  define gxmclip_INCLUDED
  25.  
  26. #include "gxclip.h"
  27.  
  28. /*
  29.  * ImageType 3 images and Patterns that don't completely fill their
  30.  * bounding box require the ability to clip against a mask.
  31.  * The interface declared here doesn't take a position on whether
  32.  * the mask will be used only in one position (ImageType 3) or in
  33.  * multiple positions for tiling (Patterns).
  34.  *
  35.  * All the information in this file is logically private, but we must expose
  36.  * the structure definition so that clients can allocate instances in the
  37.  * stack frame.
  38.  */
  39.  
  40. #define tile_clip_buffer_request 300
  41. #define tile_clip_buffer_size\
  42.   ((tile_clip_buffer_request / arch_sizeof_long) * arch_sizeof_long)
  43. typedef struct gx_device_mask_clip_s {
  44.     gx_device_forward_common;    /* target is set by client */
  45.     gx_strip_bitmap tiles;
  46.     gx_device_memory mdev;    /* for tile buffer for copy_mono */
  47.     gs_int_point phase;        /* device space origin relative */
  48.                 /* to tile (backwards from gstate phase) */
  49.     /* Ensure that the buffer is long-aligned. */
  50.     union _b {
  51.     byte bytes[tile_clip_buffer_size];
  52.     ulong longs[tile_clip_buffer_size / arch_sizeof_long];
  53.     } buffer;
  54. } gx_device_mask_clip;
  55.  
  56. extern_st(st_device_mask_clip);
  57. #define public_st_device_mask_clip()    /* in gxmclip.c */\
  58.   gs_public_st_composite_use_final(st_device_mask_clip, gx_device_mask_clip,\
  59.     "gx_device_mask_clip", device_mask_clip_enum_ptrs,\
  60.     device_mask_clip_reloc_ptrs, gx_device_finalize)
  61.  
  62. /*
  63.  * Internal routine to initialize a mask clipping device.
  64.  * We supply an explicit device space origin or phase.
  65.  * Note that this procedure does not set cdev->tiles.
  66.  */
  67. int gx_mask_clip_initialize(P7(gx_device_mask_clip * cdev,
  68.                    const gx_device_mask_clip * proto,
  69.                    const gx_bitmap * bits, gx_device * tdev,
  70.                    int tx, int ty, gs_memory_t *mem));
  71.  
  72. /*
  73.  * Prepare colors for a copy_mono operation.
  74.  * The arguments of copy_mono are free variables:
  75.  *   dev, data, sourcex, raster, id, x, y, w, y, color0, color1.
  76.  */
  77. #define setup_mask_copy_mono(cdev, color, mcolor0, mcolor1)\
  78.     BEGIN\
  79.       if ( cdev->mdev.base == 0 ) {\
  80.         /*\
  81.          * The tile was too large for us to buffer even one scan line.\
  82.          * Punt to the very, very slow default implementation of\
  83.          * copy_mono.\
  84.          */\
  85.         return gx_default_copy_mono(dev, data, sourcex, raster, id,\
  86.                     x, y, w, h, color0, color1);\
  87.       }\
  88.       if ( color1 != gx_no_color_index ) {\
  89.         if ( color0 != gx_no_color_index ) {\
  90.           /* Pre-fill with color0. */\
  91.           code =\
  92.         (*dev_proc(dev, fill_rectangle))(dev, x, y, w, h, color0);\
  93.           if ( code < 0 )\
  94.         return code;\
  95.         }\
  96.         color = color1;\
  97.         mcolor0 = 0, mcolor1 = gx_no_color_index;\
  98.       } else if ( color0 != gx_no_color_index ) {\
  99.         color = color0;\
  100.         mcolor0 = gx_no_color_index, mcolor1 = 0;\
  101.       } else\
  102.         return 0;\
  103.     END
  104.  
  105. #endif /* gxmclip_INCLUDED */
  106.